from selenium.webdriver.common.by import By
from utils.log_utils import logger
from page_object.base_page import BasePage


class ContactsPage(BasePage):
    __BTN_ADD_MEMBER = (By.LINK_TEXT, "添加成员")
    __BTN_ADD = (By.CSS_SELECTOR, ".member_colLeft_top_addBtn")
    __BTN_ADD_DEPARTMENT = (By.XPATH, "//*[text()='添加部门']")
    __TEXT_TIPS = (By.ID, "js_tips")

    def click_add_member(self):
        logger.info("点击添加成员")
        self.do_find(self.__BTN_ADD_MEMBER).click()

        from page_object.add_member_page import AddMemberPage
        return AddMemberPage(self.driver)

    def click_add_department(self):
        logger.info("点击添加部门")
        self.do_find(self.__BTN_ADD).click()
        self.do_find(self.__BTN_ADD_DEPARTMENT).click()

        from page_object.add_department_page import AddDepartmentPage
        return AddDepartmentPage(self.driver)

    def get_tips(self):
        logger.info("获取操作结果信息")

        self.wait_visible(self.__TEXT_TIPS)
        tips_value = self.do_find(self.__TEXT_TIPS).text

        return tips_value
